package com.example.vueadmin.mapper;

import com.example.vueadmin.entity.Enter;
import com.example.vueadmin.entity.Inventory;
import com.example.vueadmin.entity.InventoryVO;
import com.example.vueadmin.entity.Outer;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface InventoryMapper {

    Integer total(InventoryVO inventoryVO);

    List<Inventory> selectPage(InventoryVO inventoryVO);

    @Insert("Insert into `enter` (goods_id,ware_house_id,count,enter_time,type,cost,goods_name,ware_house_name) values (#{goodsId},#{wareHouseId},#{count},#{enterTime},#{type},#{cost},#{goodsName},#{wareHouseName})")
    Integer enterLog(Enter enter);

    @Select("SELECT *  FROM `inventory` where goods_id = #{goodsId} and ware_house_id = #{wareHouseId}")
    List<Inventory> selectGoods(Enter enter);

    @Select("SELECT goods_name from `goods` where goods_id = #{goodsId}")
    String goodsName(Integer goodsId);

    @Select("SELECT ware_house_name from `ware_house` where ware_house_id = #{wareHouseId}")
    String wareHouseName(Integer wareHouseId);

    @Insert("Insert into `inventory` (goods_id,ware_house_id,goods_name,ware_house_name,inventory,inner_time,quality) values (#{goodsId},#{wareHouseId},#{goodsName},#{wareHouseName},#{inventory},#{innerTime},#{quality})")
    Integer enter(Inventory inventory);

    @Insert("Insert into `outer` (goods_id,ware_house_id,count,outer_time,type,sale,goods_name,ware_house_name) values (#{goodsId},#{wareHouseId},#{count},#{outerTime},#{type},#{sale},#{goodsName},#{wareHouseName})")
    Integer outerLog(Outer outer);

    @Delete("Delete from `inventory` where inventory_code = #{inventoryCode}")
    Integer outer(Inventory inventory);

    @Update("update `inventory` set inventory = #{inventory} where inventory_code = #{inventoryCode}")
    Integer update(Inventory inventory);

    @Select("Select inventory from `inventory` where inventory_code = #{inventoryCode}")
    Integer selectCount(Inventory inventory);

    @Select("Select * from `enter`")
    List<Enter> queryEnter();

    @Select("Select * from `outer`")
    List<Outer> queryOuter();

}
